<%-- 
    Document   : home-page
    Created on : Apr 17, 2011, 8:30:36 PM
    Author     : dangkhoa
--%>

<%@page import="java.text.DecimalFormat"%>
<%@page import="com.vienthona.common.utils.ProductUtils"%>
<%@page import="java.util.List"%>
<%@page import="com.vienthonga.hibernate.pojo.TProduct"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>

<%
            List<TProduct> newMobilephones = (List<TProduct>) request.getAttribute("NewMobilephone");
            List<TProduct> normalMobilephones = (List<TProduct>) request.getAttribute("NormalMobilephone");
            List<TProduct> mediumMobilephones = (List<TProduct>) request.getAttribute("MediumMobilephone");
            List<TProduct> highMobilephones = (List<TProduct>) request.getAttribute("HighMobilephone");
            List<TProduct> superMobilephones = (List<TProduct>) request.getAttribute("SuperMobilephone");


            DecimalFormat format = new DecimalFormat("##,###,###");
%>
<div id="content">
    <div class="box_2">
        <div class="header Boxtitle_2">
            <span><center><b>Các Điện Thoại Mới Xuất Hiện</b></center>
            </span>
        </div>
        <div class="content">
            <div class="childContent">
                <logic:notEmpty name="NewMobilephone">

                    <table cellspacing="0" cellpadding="0" border="0" width="100%">
                        <tbody>
                            <%
                                        int count = 0;
                                        for (int i = 0; i < newMobilephones.size(); i += 4) {
                                            count = 0;

                            %>
                            <tr>
                                <%
                                                                            for (int j = i; j < newMobilephones.size(); j++) {
                                                                                TProduct newMobilephone = newMobilephones.get(j);

                                %>
                                <td align="left" width="100%" class="tdcell"><div class="product">
                                        <p></p><center><a href="./ShowMobilephoneDetail.do?P_ID=<%= newMobilephone.getPId()%>" class="producttitle"><%= newMobilephone.getPName()%></a></center><p></p>
                                        <table cellspacing="0" cellpadding="0" border="0" width="94%">
                                            <tbody><tr>
                                                    <td width="43%"><center><a class="image" href="./ShowMobilephoneDetail.do?P_ID=<%= newMobilephone.getPId()%>">
                                                                <input id="p_ID" value="<%= newMobilephone.getPId()%>"  type="hidden"/>
                                                                <img height="120" border="0" src="<%= ProductUtils.getImagePath(newMobilephone.getPPhotos(), 0)%>">
                                                            </a></center></td>
                                                </tr>
                                                <tr>
                                                    <td style="height:5px"></td>   </tr>
                                                <tr>
                                                    <td align="center" width="57%" class="ad">
                                                        <%
                                                                                                                                        //kiem tra co khuyen mai ko
                                                                                                                                        if (newMobilephone.getPPromotionsInfo() != null) {

                                                        %>
                                                        <img height="5" width="9" src="images/arrow2.gif"> Khuyến mãi
                                                        <%                                                                                                                    } else {
                                                        %>
                                                        &nbsp;

                                                        <%                                                                                                }
                                                        %>

                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="center"><span class="price"><%= format.format(newMobilephone.getPUnitPrice())%> VND</span></td>
                                                </tr>
                                            </tbody></table>
                                    </div></td>
                                    <%
                                                                                    count++;
                                                                                    if (count == 4) {
                                                                                        break;
                                                                                    }

                                                                                }

                                    %>
                            </tr>
                            <%
                                            if (i == 15) {
                                                break;
                                            }

                                        }
                            %>

                        </tbody></table>
                    </logic:notEmpty>
                <br>
                <a href="./ShowMobilephone.do?action=new" >>> Xem hết</a>
                <br>
                <br>
            </div>
        </div>
    </div>

    <div>
        <table cellspacing="0" cellpadding="0" border="0" width="596">
            <tbody><tr>
                    <td>
                        <div id="list_area">
                            <div class="list_tabs">
                                <div><a onclick="showlist(1);" href="javascript:" class="down" id="tab1">Điện thoại Siêu Cấp</a></div>
                                <div><a onclick="showlist(2);" href="javascript:" id="tab2" class="">Điện thoại Cao Cấp</a></div>
                                <div><a onclick="showlist(3);" href="javascript:" id="tab3" class="">Điện thoại Trung Cấp</a></div>
                                <div><a onclick="showlist(4);" href="javascript:" id="tab4" class="">Điện thoại Thông Dụng</a></div>
                                <br class="list_clear">
                            </div>
                            <div class="list_content">
                                <div id="list_area_1" style="">
                                    <logic:notEmpty name="SuperMobilephone">
                                        <br>
                                        <table cellspacing="0" cellpadding="0" border="0" align="center" width="98%">
                                            <tbody>
                                                <tr>
                                                    <%
                                                                for (int i = 0; i < superMobilephones.size(); i++) {
                                                                    TProduct superMobilephone = superMobilephones.get(i);

                                                    %>

                                                    <td align="left" width="100%" class="tdcell">
                                                        <div class="product">
                                                            <p></p><center>
                                                                <a href="./ShowMobilephoneDetail.do?P_ID=<%= superMobilephone.getPId()%>" class="producttitle"><%= superMobilephone.getPName()%></a></center><p></p>
                                                            <table cellspacing="0" cellpadding="0" border="0" width="94%">
                                                                <tbody>
                                                                    <tr>
                                                                        <td width="43%"><center><a class="image" href="./ShowMobilephoneDetail.do?P_ID=<%= superMobilephone.getPId()%>">
                                                                                    <input id="p_ID" value="<%= superMobilephone.getPId()%>" type="hidden"/>
                                                                                    <img height="120" border="0" src="<%= ProductUtils.getImagePath(superMobilephone.getPPhotos(), 0)%>">
                                                                                </a></center></td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td style="height:5px"></td>   </tr>
                                                                    <tr>
                                                                        <td align="center" width="57%" class="ad">
                                                                            <%
                                                                                                                                                //kiem tra co khuyen mai ko
                                                                                                                                                if (superMobilephone.getPPromotionsInfo() != null) {

                                                                            %>
                                                                            <img height="5" width="9" src="images/arrow2.gif"> Khuyến mãi
                                                                            <%                                                                                                                    } else {
                                                                            %>
                                                                            &nbsp;

                                                                            <%                                                                                                }
                                                                            %>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td align="center"><span class="price"><%= format.format(superMobilephone.getPUnitPrice())%></span></td>
                                                                    </tr>
                                                                </tbody>
                                                            </table>
                                                        </div>
                                                    </td>
                                                    <%
                                                                }
                                                    %>
                                                </tr>
                                                <tr>
                                                    <td align="right" class="producttitle" colspan="4"><br><a href="./ShowMobilephone.do?action=superMobilephone">» Xem hết&nbsp;</a>&nbsp;&nbsp;<br><br></td></tr>
                                            </tbody>
                                        </table>
                                    </logic:notEmpty>

                                </div>

                                <div id="list_area_2" style="display: none;">
                                    <logic:notEmpty name="HighMobilephone">
                                        <br>
                                        <table cellspacing="0" cellpadding="0" border="0" align="center" width="98%">
                                            <tbody>
                                                <tr>
                                                    <%
                                                                for (int i = 0; i < highMobilephones.size(); i++) {
                                                                    TProduct highMobilephone = highMobilephones.get(i);

                                                    %>

                                                    <td align="left" width="100%" class="tdcell">
                                                        <div class="product">
                                                            <p></p><center>
                                                                <a href="./ShowMobilephoneDetail.do?P_ID=<%= highMobilephone.getPId()%>" class="producttitle"><%= highMobilephone.getPName()%></a></center><p></p>
                                                            <table cellspacing="0" cellpadding="0" border="0" width="94%">
                                                                <tbody>
                                                                    <tr>
                                                                        <td width="43%"><center><a class="image" href="./ShowMobilephoneDetail.do?P_ID=<%= highMobilephone.getPId()%>">
                                                                                    <input id="p_ID" value="<%= highMobilephone.getPId()%>" type="hidden"/>
                                                                                    <img height="120" border="0" src="<%= ProductUtils.getImagePath(highMobilephone.getPPhotos(), 0)%>"
                                                                                </a></center></td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td style="height:5px"></td>   </tr>
                                                                    <tr>
                                                                        <td align="center" width="57%" class="ad">
                                                                            <%
                                                                                                                                                //kiem tra co khuyen mai ko
                                                                                                                                                if (highMobilephone.getPPromotionsInfo() != null) {

                                                                            %>
                                                                            <img height="5" width="9" src="images/arrow2.gif"> Khuyến mãi
                                                                            <%                                                                                                                    } else {
                                                                            %>
                                                                            &nbsp;

                                                                            <%                                                                                                }
                                                                            %>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td align="center"><span class="price"><%= format.format(highMobilephone.getPUnitPrice())%></span></td>
                                                                    </tr>
                                                                </tbody>
                                                            </table>
                                                        </div>
                                                    </td>
                                                    <%
                                                                }
                                                    %>
                                                </tr>
                                                <tr>
                                                    <td align="right" class="producttitle" colspan="4"><br><a href="./ShowMobilephone.do?action=highMobilephone">» Xem hết&nbsp;</a>&nbsp;&nbsp;<br><br></td></tr>
                                            </tbody>
                                        </table>
                                    </logic:notEmpty>
                                </div>

                                <div id="list_area_3" style="display: none;">
                                    <logic:notEmpty name="MediumMobilephone">
                                        <br>
                                        <table cellspacing="0" cellpadding="0" border="0" align="center" width="98%">
                                            <tbody>
                                                <tr>
                                                    <%
                                                                for (int i = 0; i < mediumMobilephones.size(); i++) {
                                                                    TProduct mediumMobilephone = mediumMobilephones.get(i);

                                                    %>

                                                    <td align="left" width="100%" class="tdcell">
                                                        <div class="product">
                                                            <p></p><center>
                                                                <a href="./ShowMobilephoneDetail.do?P_ID=<%= mediumMobilephone.getPId()%>" class="producttitle"><%= mediumMobilephone.getPName()%></a></center><p></p>
                                                            <table cellspacing="0" cellpadding="0" border="0" width="94%">
                                                                <tbody>
                                                                    <tr>
                                                                        <td width="43%"><center><a class="image" href="./ShowMobilephoneDetail.do?P_ID=<%= mediumMobilephone.getPId()%>">
                                                                                    <input id="p_ID" value="<%= mediumMobilephone.getPId()%>" type="hidden"/>
                                                                                    <img height="120" border="0" src="<%= ProductUtils.getImagePath(mediumMobilephone.getPPhotos(), 0)%>">
                                                                                </a></center></td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td style="height:5px"></td>   </tr>
                                                                    <tr>
                                                                        <td align="center" width="57%" class="ad">
                                                                            <%
                                                                                                                                                //kiem tra co khuyen mai ko
                                                                                                                                                if (mediumMobilephone.getPPromotionsInfo() != null) {

                                                                            %>
                                                                            <img height="5" width="9" src="images/arrow2.gif"> Khuyến mãi
                                                                            <%                                                                                                                    } else {
                                                                            %>
                                                                            &nbsp;

                                                                            <%                                                                                                }
                                                                            %>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td align="center"><span class="price"><%= format.format(mediumMobilephone.getPUnitPrice())%></span></td>
                                                                    </tr>
                                                                </tbody>
                                                            </table>
                                                        </div>
                                                    </td>
                                                    <%
                                                                }
                                                    %>
                                                </tr>
                                                <tr>
                                                    <td align="right" class="producttitle" colspan="4"><br><a href="./ShowMobilephone.do?action=mediumMobilephone">» Xem hết&nbsp;</a>&nbsp;&nbsp;<br><br></td></tr>
                                            </tbody>
                                        </table>
                                    </logic:notEmpty>
                                </div>
                                <div id="list_area_4" style="display: none;">
                                    <logic:notEmpty name="NormalMobilephone">
                                        <br>
                                        <table cellspacing="0" cellpadding="0" border="0" align="center" width="98%">
                                            <tbody>
                                                <tr>
                                                    <%
                                                                for (int i = 0; i < normalMobilephones.size(); i++) {
                                                                    TProduct normalMobilephone = normalMobilephones.get(i);

                                                    %>

                                                    <td align="left" width="100%" class="tdcell">
                                                        <div class="product">
                                                            <p></p><center>
                                                                <a href="./ShowMobilephoneDetail.do?P_ID=<%= normalMobilephone.getPId()%>" class="producttitle"><%= normalMobilephone.getPName()%></a></center><p></p>
                                                            <table cellspacing="0" cellpadding="0" border="0" width="94%">
                                                                <tbody>
                                                                    <tr>
                                                                        <td width="43%"><center><a class="image" href="./ShowMobilephoneDetail.do?P_ID=<%= normalMobilephone.getPId()%>">
                                                                                    <input id="p_ID" value="<%= normalMobilephone.getPId()%>" type="hidden"/>
                                                                                    <img height="120" border="0" src="<%= ProductUtils.getImagePath(normalMobilephone.getPPhotos(), 0)%>">
                                                                                </a></center></td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td style="height:5px"></td>   </tr>
                                                                    <tr>
                                                                        <td align="center" width="57%" class="ad">
                                                                            <%
                                                                                                                                                //kiem tra co khuyen mai ko
                                                                                                                                                if (normalMobilephone.getPPromotionsInfo() != null) {

                                                                            %>
                                                                            <img height="5" width="9" src="images/arrow2.gif"> Khuyến mãi
                                                                            <%                                                                                                                    } else {
                                                                            %>
                                                                            &nbsp;

                                                                            <%                                                                                                }
                                                                            %>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td align="center"><span class="price"><%= format.format(normalMobilephone.getPUnitPrice())%></span></td>
                                                                    </tr>
                                                                </tbody>
                                                            </table>
                                                        </div>
                                                    </td>
                                                    <%
                                                                }
                                                    %>
                                                </tr>
                                                <tr>
                                                    <td align="right" class="producttitle" colspan="4"><br><a href="./ShowMobilephone.do?action=normalMobilephone">» Xem hết&nbsp;</a>&nbsp;&nbsp;<br><br></td></tr>
                                            </tbody>
                                        </table>
                                    </logic:notEmpty>

                                </div>
                            </div>

                        </div>
                    </td>
                </tr>
            </tbody>
        </table>
        <script type="text/javascript" language="javascript">
            function hidelist()
            {
                document.getElementById("list_area_1").style.display= 'none';
                document.getElementById("list_area_2").style.display= 'none';
                document.getElementById("list_area_3").style.display= 'none';
                document.getElementById("list_area_4").style.display= 'none';
                document.getElementById('tab1').className='';
                document.getElementById('tab2').className='';
                document.getElementById('tab3').className='';
                document.getElementById('tab4').className='';
            }

            function showlist(id)
            {
                hidelist();
                document.getElementById("list_area_" + id).style.display='';
                document.getElementById('tab' + id).className='down';
            }
            showlist(1);
        </script>

    </div>
</div>
<script type="text/javascript" src="js/jquery-1.5.2.min.js"></script>
<script type="text/javascript" src="js/jquery.tooltip.js" ></script>
<script type="text/javascript" >
    $("document").ready( function() {

        $(".image").tooltip( {
            track: true,
            delay: 0,
            showURL: false,
            opacity: 1,
            fixPNG: true,
            showBody: " - ",
            extraClass: "pretty",
            top: -15,
            left: 20,
            bodyHandler: function(){
                var p_ID = $(this).children('input').attr('value');
                //var p_ID = 'PHTC0001';
                var msgTemp ;
                var sendData = "P_ID=" + p_ID;
                $.ajax({
                    type: "GET",
                    url: "./ShowProductTooltip.do",
                    data: sendData ,
                    async: false,
                    success: function(msg)
                    {
                        msgTemp = msg;
                    }

                }); //end ajax

                if(msgTemp != undefined)
                {

                    var str = "<table width='350' height='120' border='0' cellspacing='0' cellpadding='0'> <tr> <td height='20' align='center' bgcolor='#000000' style='color:#FFF' > <strong>Tính Năng Nổi Bật<\/strong> <\/td> <\/tr> ";
                    str += "<tr> <td> <strong>Màn hình<\/strong>:"+ msgTemp.display.displayType +"; "+ msgTemp.display.displaySize +"<\/td> <\/tr>"
                    str += "<tr> <td> <strong>Bộ Nhớ<\/strong>:"+msgTemp.storage.contact +"; "+msgTemp.storage.internalMemory +"; "+msgTemp.storage.externalMemory +"<\/td> <\/tr>"
                    str += "<tr> <td><strong>Nhạc chuông<\/strong>:"+ msgTemp.orthers.musicDownload +"; "+msgTemp.orthers.ring_2 +"<\/td> <\/tr>"
                    str += "<tr> <td><strong>Hệ Điều Hành:<\/strong>:"+ msgTemp.orthers.os +"<\/td> <\/tr>"
                    str += "<\/table>";
                    return  $(str);
                }
                return "";

            } // end body handler
        });

    });
</script>